{extend name="public/common"} {block name="body"}
<title>基本设置</title>
</head>
<style type="text/css">
.radius:hover{
 	color: #fff;
	border-color: #66b1ff;
	background-color: #66b1ff;
 }
 span:hover{
 	color: #333;
 }
 .btn-primary {
    color: #fff;
    background-color: #5a98de;
    border-color: #5a98de;
    height: 31px;
    border-radius: 5px;
    font-size: 14px;
    line-height: 24px !important;
}
</style>
<body>
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i>
		系统管理
		<span class="c-gray en">&gt;</span>
		运营管理
		<span class="c-gray en">&gt;</span>
		外部客服
		<span class="c-gray en">&gt;</span>
		添加客服
		<a class="btn btn-success radius r"
			style="line-height: 1.6em; margin-top: 3px"
			href="javascript:location.replace(location.href);" title="刷新">
			<i class="Hui-iconfont">&#xe68f;</i>
		</a>
	</nav>
	<article class="page-container">
		<form class="form form-horizontal" action="" id="form-admin-add" method="post">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">客服名称：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" id="name" name="name">
				</div>
				<span id="a1" style="display:none;"></span>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">客服QQ号/微信号：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" id="qq" name="qq">
				</div>
				<span id="b1" style="display:none;"></span>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">客服分类：</label>
				<div class="formControls col-xs-8 col-sm-9 skin-minimal">
					<div class="radio-box">
						<input type="radio" id="sex-0" name="type" value="0" checked>
						<label for="sex-0">游客QQ客服</label>
					</div>
					<div class="radio-box" style="padding-left: 0px;">
						<input name="type" type="radio" id="sex-1" value="1"/>
						<label for="sex-1">会员QQ客服</label>
					</div>
					<div class="radio-box">
						<input type="radio" id="sex-3" name="type" value="2" />
						<label for="sex-3">游客微信客服</label>
					</div>
					<div class="radio-box">
						<input type="radio" id="sex-4" name="type" value="3"/>
						<label for="sex-4">会员微信客服</label>
					</div>
					
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2" >
					<button class="btn btn-primary radius" name="submit" type="button" id="tijiao"><i class="Hui-iconfont">&#xe632;</i>保存</button>
					<input type="button" style="margin-left:5px;" onclick="JavaScript:history.go(-1)" class="btn btn-primary radius"  value="返回" />
				</div>
			</div>
		</form>
	</article>
	<script>
	
	$("#tijiao").click(function(){
		var name=$('#name').val();
		var qq=$('#qq').val();
		var radio = document.getElementsByName('type');
		var type;
		for(var i=0;i<radio.length;i++){
			if(radio[i].checked){
				type=radio[i].value;
			}
		}
		var han = /^[\u4e00-\u9fa5]+$/;
		if(name==''){
			$("#a1").css('display','block').html('客服名称不能为空');
			return false;
		}else if(qq==''){
			$("#b1").css('display','block').html('客服QQ不能为空');
			return false;
		}else{
			if(han.test(name)){
				$("#a1").css('display','none');
					$("#b1").css('display','none');
					$.ajax({
						type:'POST',
				          url:"{:url('Systemsettings/add_kefu')}",
				          data:{
				            'name':name,'qq':qq,'type':type
				          },
				          success:function(data){
				        	  if(data=='1'){
				        		  alert('添加成功');
				        	  }else if(data=='0'){
				        		  alert('添加失败');
				        	  }else if(data=="2"){
				        		  alert('客服名称不能为空');
				        	  }else if(data=="3"){
				        		  alert('QQ号码不能为空');
				        	  }
				          },
				          error:function(msg){
				        	  alert(msg);
				          }
					});
			}else{
				$("#a1").css('display','block').html('客服名称必须为汉字');
				return false;
			}
		}
	});
	</script>
	{/block}